package org.example.service.impl;

import org.example.mapper.EmpMapper;
import org.example.mapper.StudentMapper;
import org.example.pojo.JobOption;
import org.example.pojo.StudentOption;
import org.example.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService{
    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public List<Map<String, Object>> getStudentDegreeData(){
        return studentMapper.getStudentDegreeData();
    }

    @Override
    public StudentOption getStudentCountData(){
        List<Map<String, Object> > studentCountList = studentMapper.getStudentCountData();
        System.out.println(studentCountList);
        List<Object> clazzList = studentCountList.stream().map(dataMap -> dataMap.get("pos")).toList();
        List<Object> dataList = studentCountList.stream().map(dataMap -> dataMap.get("num")).toList();
        return new StudentOption(clazzList, dataList);
    }

    @Override
    public List<Map<String, Object>> getEmpGenderData(){
        return empMapper.getEmpGenderData();
    }

    @Override
    public JobOption getEmpJobData(){
        List<Map<String, Object>> empJobData = empMapper.getEmpJobData();
        List<Object> jobList = empJobData.stream().map(dataMap -> dataMap.get("pos")).toList();
        List<Object> dataList = empJobData.stream().map(dataMap -> dataMap.get("num")).toList();
        return new JobOption(jobList,dataList);
    }
}
